﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bovril.SmallWorld.Core
{
    public static class BoardFactory
    {
        public static IBoard CreateStandardTwoPlayerBoard()
        {
            BoardBuilder boardBuilder = new BoardBuilder();

            BoardRegion col0Row0 = boardBuilder.AddBoardRegion("Outer 0 (Top Left)", Terrain.Type.Water, true);
            BoardRegion col0Row1 = boardBuilder.AddBoardRegion("Outer 14", Terrain.Type.Mountain, true);
            BoardRegion col0Row2 = boardBuilder.AddBoardRegion("Outer 13", Terrain.Type.Plains, true);
            BoardRegion col0Row3 = boardBuilder.AddBoardRegion("Outer 12", Terrain.Type.Swamp, true);

            BoardRegion col1Row0 = boardBuilder.AddBoardRegion("Outer 1", Terrain.Type.Plains, true);
            BoardRegion col1Row1 = boardBuilder.AddBoardRegion("Inner 0", Terrain.Type.Hills, false);
            BoardRegion col1Row2 = boardBuilder.AddBoardRegion("Inner 7", Terrain.Type.Forest, false);
            BoardRegion col1Row3 = boardBuilder.AddBoardRegion("Outer 11", Terrain.Type.Hills, true);

            BoardRegion col2Row0 = boardBuilder.AddBoardRegion("Outer 2", Terrain.Type.Forest, true);
            BoardRegion col2Row1 = boardBuilder.AddBoardRegion("Inner 1", Terrain.Type.Water, false);
            BoardRegion col2Row2 = boardBuilder.AddBoardRegion("Outer 10", Terrain.Type.Swamp, true);

            BoardRegion col3Row0 = boardBuilder.AddBoardRegion("Outer 3", Terrain.Type.Swamp, true);
            BoardRegion col3Row1 = boardBuilder.AddBoardRegion("Inner 2", Terrain.Type.Mountain, false);
            BoardRegion col3Row2 = boardBuilder.AddBoardRegion("Inner 6", Terrain.Type.Plains, false);
            BoardRegion col3Row3 = boardBuilder.AddBoardRegion("Outer 9", Terrain.Type.Mountain, true);

            BoardRegion col4Row0 = boardBuilder.AddBoardRegion("Inner 3", Terrain.Type.Plains, false);
            BoardRegion col4Row1 = boardBuilder.AddBoardRegion("Inner 4", Terrain.Type.Hills, false);
            BoardRegion col4Row2 = boardBuilder.AddBoardRegion("Outer 8", Terrain.Type.Swamp, true);

            BoardRegion col5Row0 = boardBuilder.AddBoardRegion("Outer 4", Terrain.Type.Hills, true);
            BoardRegion col5Row1 = boardBuilder.AddBoardRegion("Outer 5", Terrain.Type.Forest, true);
            BoardRegion col5Row2 = boardBuilder.AddBoardRegion("Outer 6", Terrain.Type.Mountain, true);
            BoardRegion col5Row3 = boardBuilder.AddBoardRegion("Inner 5", Terrain.Type.Forest, false);
            BoardRegion col5Row4 = boardBuilder.AddBoardRegion("Outer 7", Terrain.Type.Water, true);

            boardBuilder.ConnectBoardRegions(col0Row0, col0Row1);
            boardBuilder.ConnectBoardRegions(col0Row0, col1Row0);
            boardBuilder.ConnectBoardRegions(col0Row1, col1Row0);
            boardBuilder.ConnectBoardRegions(col0Row1, col1Row1);
            boardBuilder.ConnectBoardRegions(col0Row1, col0Row2);
            boardBuilder.ConnectBoardRegions(col0Row2, col1Row1);
            boardBuilder.ConnectBoardRegions(col0Row2, col1Row2);
            boardBuilder.ConnectBoardRegions(col0Row2, col1Row3);
            boardBuilder.ConnectBoardRegions(col0Row2, col0Row3);
            boardBuilder.ConnectBoardRegions(col0Row3, col1Row3);

            boardBuilder.ConnectBoardRegions(col1Row0, col2Row0);
            boardBuilder.ConnectBoardRegions(col1Row0, col1Row1);
            boardBuilder.ConnectBoardRegions(col1Row1, col2Row0);
            boardBuilder.ConnectBoardRegions(col1Row1, col2Row1);
            boardBuilder.ConnectBoardRegions(col1Row1, col1Row2);
            boardBuilder.ConnectBoardRegions(col1Row2, col2Row1);
            boardBuilder.ConnectBoardRegions(col1Row2, col3Row2);
            boardBuilder.ConnectBoardRegions(col1Row2, col2Row2);
            boardBuilder.ConnectBoardRegions(col1Row2, col1Row3);
            boardBuilder.ConnectBoardRegions(col1Row3, col2Row2);

            boardBuilder.ConnectBoardRegions(col2Row0, col3Row0);
            boardBuilder.ConnectBoardRegions(col2Row0, col3Row1);
            boardBuilder.ConnectBoardRegions(col2Row0, col2Row1);
            boardBuilder.ConnectBoardRegions(col2Row1, col3Row1);
            boardBuilder.ConnectBoardRegions(col2Row1, col3Row2);
            boardBuilder.ConnectBoardRegions(col2Row2, col3Row2);
            boardBuilder.ConnectBoardRegions(col2Row2, col3Row3);

            boardBuilder.ConnectBoardRegions(col3Row0, col5Row0);
            boardBuilder.ConnectBoardRegions(col3Row0, col4Row0);
            boardBuilder.ConnectBoardRegions(col3Row0, col3Row1);
            boardBuilder.ConnectBoardRegions(col3Row1, col4Row0);
            boardBuilder.ConnectBoardRegions(col3Row1, col4Row1);
            boardBuilder.ConnectBoardRegions(col3Row1, col3Row2);
            boardBuilder.ConnectBoardRegions(col3Row2, col4Row1);
            boardBuilder.ConnectBoardRegions(col3Row2, col4Row2);
            boardBuilder.ConnectBoardRegions(col3Row2, col3Row3);
            boardBuilder.ConnectBoardRegions(col3Row3, col4Row2);

            boardBuilder.ConnectBoardRegions(col4Row0, col5Row0);
            boardBuilder.ConnectBoardRegions(col4Row0, col5Row1);
            boardBuilder.ConnectBoardRegions(col4Row0, col4Row1);
            boardBuilder.ConnectBoardRegions(col4Row1, col5Row1);
            boardBuilder.ConnectBoardRegions(col4Row1, col5Row2);
            boardBuilder.ConnectBoardRegions(col4Row1, col5Row3);
            boardBuilder.ConnectBoardRegions(col4Row1, col4Row2);
            boardBuilder.ConnectBoardRegions(col4Row2, col5Row3);
            boardBuilder.ConnectBoardRegions(col4Row2, col5Row4);

            boardBuilder.ConnectBoardRegions(col5Row0, col5Row1);
            boardBuilder.ConnectBoardRegions(col5Row1, col5Row2);
            boardBuilder.ConnectBoardRegions(col5Row2, col5Row3);
            boardBuilder.ConnectBoardRegions(col5Row2, col5Row4);
            boardBuilder.ConnectBoardRegions(col5Row3, col5Row4);
            
            return boardBuilder.ToIBoard();
        }
    }
}
